package com.test.ml.yqs.entity;

/**
 * 开奖号码
 */
public class OpenCode implements  Comparable{
    /**
     * 开奖号码
     */
    private String opencode;
    /**
     * 开奖的第一个号码
     */
    private Integer onenum;
    /**
     * 开奖的第二个号码
     */
    private Integer twonum;
    /**
     * 开奖的第3个号码
     */
    private Integer thridnum;
    /**
     * 开奖的第4个号码
     */
    private Integer founum;
    /**
     * 开奖的第5个号码
     */
    private Integer fivnum;
    /**
     * 开奖的期数
     */
    private String perioud;

    public String getOpencode() {
        return opencode;
    }

    public void setOpencode(String opencode) {
        this.opencode = opencode;
    }

    public Integer getOnenum() {
        return onenum;
    }

    public void setOnenum(Integer onenum) {
        this.onenum = onenum;
    }

    public Integer getTwonum() {
        return twonum;
    }

    public void setTwonum(Integer twonum) {
        this.twonum = twonum;
    }

    public Integer getThridnum() {
        return thridnum;
    }

    public void setThridnum(Integer thridnum) {
        this.thridnum = thridnum;
    }

    public Integer getFounum() {
        return founum;
    }

    public void setFounum(Integer founum) {
        this.founum = founum;
    }

    public Integer getFivnum() {
        return fivnum;
    }

    public void setFivnum(Integer fivnum) {
        this.fivnum = fivnum;
    }

    public String getPerioud() {
        return perioud;
    }

    public void setPerioud(String perioud) {
        this.perioud = perioud;
    }


    public OpenCode(String opencode, String perioud) {
        this.opencode = opencode;
        this.perioud = perioud;
        this.onenum=Integer.parseInt(opencode.substring(0,1));
        this.twonum=Integer.parseInt(opencode.substring(2,3));
        this.thridnum=Integer.parseInt(opencode.substring(4,5));
        this.founum=Integer.parseInt(opencode.substring(6,7));
        this.fivnum=Integer.parseInt(opencode.substring(8,9));
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
       if(obj instanceof OpenCode ){
          if (((OpenCode) obj).getPerioud().equals(this.perioud)){
              return true;
          }
       }
       return false;
    }

    @Override
    public int compareTo(Object o) {
        OpenCode code= (OpenCode) o;
        if(Integer.parseInt(this.perioud)>Integer.parseInt(code.getPerioud())){
            return 1;
        }else if(Integer.parseInt(this.perioud)<Integer.parseInt(code.getPerioud())){
            return -1;
        }else{
            return 0;
        }
    }

    @Override
    public String toString() {
        return "OpenCode{" +
                "opencode='" + opencode + '\'' +
                ", perioud='" + perioud + '\'' +
                '}';
    }
}
